<?php
/**
 * Created by PhpStorm.
 * User: tjjs
 * Date: 17-7-20
 * Time: 下午12:23
 */

namespace ActionsHttp;

use Data\Food_DAO;
use Data\Food_groups_DAO;
use Data\Restaurant_DAO;

class ConsumerGetFoodList extends BaseActionHttp
{
    public function doAction() {
        parent::doAction();
        // 商铺id
        $restaurant_id = (int)$this->data[RESTAURANT_ID];

        // 商铺记录
        $restaurant_record = Restaurant_DAO::getRecord($restaurant_id);
        if (!$restaurant_record) {
            return $this->SendErrMsg("没有该商铺记录");
        }

        // 商品分类排序
        $food_groups_order = $restaurant_record->getFOOD_GROUPS_ORDER();

        // 商品分类列表
        $food_groups_list = Food_groups_DAO::getArrayByRestaurantId($restaurant_id);

        // 商品列表
        $food_list = Food_DAO::getArrayByRestaurantId($restaurant_id);

        // 返回数据
        $this->setValue(FOOD_GROUPS_ORDER,$food_groups_order);
        $this->setValue(Food_groups_list,$food_groups_list);
        $this->setValue(Food_list,$food_list);
        $this->ResponseDataToCurrentClient();
    }
}